import { baseUrl } from './http.js'

module.exports = {
  request : function(url, methodType, data){
    let fullUrl = `${baseUrl}${url}`
    // let token = wx.getStorageSync('token') ? wx.getStorageSync('token')  : ''
    return new Promise((resolve,reject)=>{
      wx.request({
        url: fullUrl,
        method: methodType,
        data: data,
        header: {
          'content-type': 'application/json', // 默认值
          // 'x-api-key': token,
        },
        success(res){
            resolve(res);
        },
        fail(){
          wx.showToast({
            title: '网络错误',
            icon:'none'
          })
          reject('网络错误')
        }
      })
    })
  }
}